﻿using System;
using System.Web;
using System.IO;
using System.Text;
using System.Drawing;
using System.Web.Mail;
using System.Collections;
using System.Web.Security;
using System.Resources;
using System.Globalization;
using System.Threading;
using System.Configuration.Assemblies;
using System.Reflection;
using Telerik.Web.UI;

/// <summary>
/// Summary description for BasePage
/// </summary>
public static class BasePage
{
    // This function is used in set language and culture 
    public static void SetLocalCulture()
    {
        if (HttpContext.Current.Session["Lang"] == null)
            HttpContext.Current.Session["Lang"] = "en-US";

        System.Globalization.CultureInfo cultureInfo = null;
        cultureInfo = new CultureInfo(HttpContext.Current.Session["Lang"].ToString());
        System.Threading.Thread.CurrentThread.CurrentCulture = cultureInfo;
        System.Threading.Thread.CurrentThread.CurrentUICulture = cultureInfo;
        CultureInfo.CurrentUICulture.DateTimeFormat = CultureInfo.CurrentCulture.DateTimeFormat = new CultureInfo("en-US", false).DateTimeFormat;        
    }

    public static string FormatDate(DateTime date)
    {
        return date.ToString("dd.MM.yy");
    }

    public static string FormatTime(DateTime date)
    {
        return date.ToString("hh.mm tt");
    }

    // export data function
    public static RadGrid Grid { get; set; }
    
    public static void ExpoprtInExcel(RadGrid RadGrid1)
    {
        string FileName = RadGrid1.ID + "-" + System.DateTime.Today.ToString("dd-MM-yyyy");
        RadGrid1.ExportSettings.FileName = FileName;
        RadGrid1.ExportSettings.IgnorePaging = true;
        RadGrid1.ExportSettings.ExportOnlyData = true;
        RadGrid1.MasterTableView.ExportToExcel();
    }

}
